package com.mega.fe.fuck;

import com.mega.fe.util.BaseInit;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import net.minecraft.client.gui.Font;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;

public class FuckRenderEntity extends EntityRenderDispatcher {
    public boolean isAble(Entity entity) {
            if (entity instanceof LivingEntity l)
                return l.deathTime < 20;
            return false;
    }
    public FuckRenderEntity(Minecraft p_234579_, TextureManager p_234580_, ItemRenderer p_234581_, BlockRenderDispatcher p_234582_, Font p_234583_, Options p_234584_, EntityModelSet p_234585_) {
        super(p_234579_, p_234580_, p_234581_, p_234582_, p_234583_, p_234584_, p_234585_);
    }

    @Override
    public <E extends Entity> boolean shouldRender(E p_114398_, Frustum p_114399_, double p_114400_, double p_114401_, double p_114402_) {
        if (BaseInit.isDeath(p_114398_))
            return isAble(p_114398_);
        return super.shouldRender(p_114398_, p_114399_, p_114400_, p_114401_, p_114402_);
    }

    @Override
    public <T extends Entity> EntityRenderer<? super T> getRenderer(T p_114383_) {
        if (p_114383_ == null)
            return null;
        return super.getRenderer(p_114383_);
    }

    @Override
    public <E extends Entity> void render(E p_114385_, double p_114386_, double p_114387_, double p_114388_, float p_114389_, float p_114390_, PoseStack p_114391_, MultiBufferSource p_114392_, int p_114393_) {
        if (BaseInit.isDeath(p_114385_)) {
            if (p_114385_ instanceof LivingEntity l) {
                if (l.deathTime >= 20)
                    return;
            } else return;
        }
        super.render(p_114385_, p_114386_, p_114387_, p_114388_, p_114389_, p_114390_, p_114391_, p_114392_, p_114393_);
    }

    @Override
    public void prepare(Level p_114409_, Camera p_114410_, Entity p_114411_) {
        if (BaseInit.isDeath(p_114411_)) {
            if (p_114411_ instanceof LivingEntity l) {
                if (l.deathTime >= 20)
                    return;
            } else return;
        }
        super.prepare(p_114409_, p_114410_, p_114411_);
    }

}
